package com.ky.pro.big.data.mr.mobile.dr.dto;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class MobileDataRateInfo implements Writable {

    long msisdn;

    int upRate;

    int downRate;

    int totalRate;

    public MobileDataRateInfo() {
    }

    public MobileDataRateInfo(long msisdn, int upRate, int downRate) {
        this.msisdn = msisdn;
        this.upRate = upRate;
        this.downRate = downRate;
        this.totalRate = upRate + downRate;
    }

    public int getUpRate() {
        return upRate;
    }

    public int getDownRate() {
        return downRate;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeLong(msisdn);
        out.writeInt(upRate);
        out.writeInt(downRate);
        out.writeInt(totalRate);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        msisdn = in.readLong();
        upRate = in.readInt();
        downRate = in.readInt();
        totalRate = in.readInt();
    }

    @Override
    public String toString() {
        return msisdn + " " + upRate + " " + downRate + " " + totalRate;
    }
}
